<?php
    function authUtil($require_perm,$perm_array,$operator){
        //AND
        if($operator){
            $authorized = true;
            for($i=0;$i<count($require_perm);$i++){
                if (!in_array($require_perm[$i],$perm_array,true)){
                   return false; 
                }
            }
            return $authorized;
        }
        //OR
        else{
            $authorized = false;
            for($i=0;$i<count($require_perm);$i++){
                if (in_array($require_perm[$i],$perm_array,true)){
                    $authorized = true;        
                }
            }
            return $authorized;
        }     
    } 
?> 